package com.pjedu.springbootquick01.web;

import com.pjedu.springbootquick01.entity.MySqlEntity;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.sql.DataSource;

/**
 * @Author 汪洋
 * @Description
 */
@RestController
public class DemoController {
    @Value("${student.name}")
    private String name;
    @Value("${student.sex}")
    private String sex;

    @RequestMapping("yml1")
    public Object yml1(){
        return name+","+sex;
    }
    @Value("${person.name}")
    private String username;
    @Value("${person.age}")
    private int age;

    @RequestMapping("yml")
    public Object yml(){
        return username+","+age;
    }
    @Resource
    private DataSource dataSource;

    @RequestMapping("data")
    public Object data(){
        System.out.println(dataSource);
        return "datasource";
    }

    @Resource
    private MySqlEntity mySqlEntity;

    @RequestMapping("jdbc")
    public Object jdbc(){
        return mySqlEntity;
    }
    @RequestMapping("demo")
    public String demo(){
        return "Welcome to SpringBoot1";
    }
}
